//
//  SelectQuestionSystem.cpp
//  QuizMaster
//
//  Created by Jeppe Nielsen on 3/22/15.
//  Copyright (c) 2015 Jeppe Nielsen. All rights reserved.
//

#include "SelectQuestionSystem.hpp"
#include "Touchable.hpp"
#include <iostream>
#include "TransformAnimator.hpp"
#include "Orderable.hpp"
#include "MathHelper.hpp"

void SelectQuestionSystem::Initialize() {
    AddComponent<Touchable>();
    AddComponent<QuestionComponent>();
    AddComponent<Transform>();
}

void SelectQuestionSystem::ObjectAdded(Nano::GameObject *object) {
    object->GetComponent<Touchable>()->Click += event_handler(this, &SelectQuestionSystem::QuestionClicked, object);
}

void SelectQuestionSystem::ObjectRemoved(Nano::GameObject *object) {
   object->GetComponent<Touchable>()->Click -= event_handler(this, &SelectQuestionSystem::QuestionClicked, object);
}

void SelectQuestionSystem::QuestionClicked(Nano::TouchData d, Nano::GameObject *object) {
    QuestionSelected(object->Parent);
}

bool SelectQuestionSystem::NoMoreQuestions() {
    return Objects().empty();
}